
<%@page import="java.util.Date"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ request.getContextPath() + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<title>Insert title here</title>
</head>
<body>
 <h1>session内置对象</h1>
 <%
   SimpleDateFormat sdf=new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");
   Date d = new Date(session.getCreationTime());
   session.setAttribute("username", "admin");
   session.setAttribute("password", "123456");
   session.setAttribute("age", 22);
   session.setMaxInactiveInterval(100);
   //session.invalidate();
 %>
 session创建时间：<%=sdf.format(d) %><br>
 session的ID编号：<%=session.getId() %><br>
 从session中获取用户名：<%=session.getAttribute("username") %><br>
 <a href="session_page2.jsp" target="_blank">跳转到session_page2页面</a><br>
</body>
</html>